package p1850;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class CF1850C {
    static char[][] a;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8);
        int t = scanner.nextInt();
        while (t-- > 0) {
            a = new char[8][8];
            for (int i = 0; i < 8; i++) {
                a[i] = scanner.next().toCharArray();
            }
            System.out.println(solve());
        }
    }

    private static String solve() {
        StringBuilder ans = new StringBuilder();
        for (int j = 0; j < 8; j++) {
            for (int i = 0; i < 8; i++) {
                if (a[i][j] != '.') {
                    ans.append(a[i][j]);
                }
            }
        }
        return ans.toString();
    }
}
/*
C. Word on the Paper
https://codeforces.com/contest/1850/problem/C

题目大意：
在 8×8 的点网格上，一个由小写拉丁字母组成的单词从上到下垂直地写在一列中。这是什么?

模拟。
======

input
5
........
........
........
........
...i....
........
........
........
........
.l......
.o......
.s......
.t......
........
........
........
........
........
........
........
......t.
......h.
......e.
........
........
........
........
........
.......g
.......a
.......m
.......e
a.......
a.......
a.......
a.......
a.......
a.......
a.......
a.......
output
i
lost
the
game
aaaaaaaa
 */
